﻿<UserControl x:Class="DeltaGroup.WheelOfJeopardy.UI.Screens.GameSetup"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Commands="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Commands" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Model="clr-namespace:DeltaGroup.WheelOfJeopardy.Model" mc:Ignorable="d" 
             x:Name="setupControl" Background="{StaticResource ScreenBackgroundBrushKey}">
    <UserControl.CommandBindings>
        <CommandBinding Command="Commands:WoJCommands.Start" CanExecute="CanStart"  />
    </UserControl.CommandBindings>

    <Grid Width="400" HorizontalAlignment="Center"  >
        <Border Padding="10">
            <StackPanel>
                <TextBlock Text="Game Setup" Style="{StaticResource Title}"/>
                <GroupBox Padding="10">
                    <GroupBox.Header>
                        <TextBlock Text="Game File" Style="{StaticResource Header}"/>
                    </GroupBox.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="160" />
                            <ColumnDefinition Width="19*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="22*" />
                            <RowDefinition Height="16*" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Column="0" Grid.Row="0" Text="Choose a game set to start: " Margin="0,0,0,10"/>
                        <ComboBox Grid.Column="1" Name="cbFiles" ItemsSource="{Binding ChallengeFiles}" Margin="0,0,0,10" >
                            <ComboBox.SelectedValue>
                                <Binding Path="SelectedChallengeFile" BindsDirectlyToSource="True" ValidatesOnDataErrors="True" />
                            </ComboBox.SelectedValue>
                        </ComboBox>
                        <TextBlock Text="Difficulty" Grid.Row="1" Grid.ColumnSpan="2" />
                        <ListBox Grid.Column="1" Grid.Row="1" SelectedValue="{Binding Path=Difficulty}" Style="{StaticResource HorizontalRadioButtonList}" ItemsSource="{Binding Source={StaticResource difficultyOptions}}" Grid.ColumnSpan="2">
                        </ListBox>
                    </Grid>
                </GroupBox>
                <GroupBox Padding="10">
                    <GroupBox.Header>
                        <TextBlock Text="Players" Style="{StaticResource Header}"/>
                    </GroupBox.Header>
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Number of Contestants:"/>
                            <ListBox  SelectedValue="{Binding Path=NumberOfContestants, BindsDirectlyToSource=True}" SelectedValuePath="Content" Style="{StaticResource HorizontalRadioButtonList}" >
                                <ListBox.Items>
                                    <ListBoxItem Content="2" />
                                    <ListBoxItem Content="3" />
                                    <ListBoxItem Content="4" />
                                </ListBox.Items>
                            </ListBox>
                        </StackPanel>
                        <Separator BorderThickness="4" BorderBrush="White" Margin="0,7" />
                        <ItemsControl Name="itemsControl" ItemsSource="{Binding Path=Contestants, BindsDirectlyToSource=True, NotifyOnSourceUpdated=True, Mode=TwoWay, NotifyOnValidationError=True}" >
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid Margin="5">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="3*" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock>
                                            <TextBlock.Text>
                                                <MultiBinding StringFormat="Contestant {0}">
                                                    <Binding Path="Index" />
                                                </MultiBinding>
                                            </TextBlock.Text>
                                        </TextBlock>
                                        <TextBox Grid.Column="1" >
                                            <TextBox.Text>
                                                <Binding Path="Name" UpdateSourceTrigger="PropertyChanged" ValidatesOnDataErrors="True" NotifyOnValidationError="True">
                                                </Binding>
                                            </TextBox.Text>
                                        </TextBox>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </GroupBox>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                </Grid>

                <Grid Margin="20">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Button Margin="5,0" Content="Cancel" Grid.Column="0" Command="Commands:WoJCommands.Menu" />
                    <Button Margin="5,0" Content="Start Game" Grid.Column="1" Command="Commands:WoJCommands.Start" CommandParameter="{Binding}"/>
                </Grid>

            </StackPanel>
        </Border>
    </Grid>
</UserControl>
